<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="com.model.GameModel"%>
<%@page import="com.dao.GameDao"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"
%>
<html>
	<head>
		<style type="text/css">
			.titulo{
				font-weight: bold;
				margin-top: 0px;
			}
		</style>
	</head>
	<body>
		<%
			int maxCols=4;
			GameDao gameDao = new GameDao();
			List<GameModel> gameModels = new ArrayList<GameModel>();
		%>
		<form method="get" action="<%=request.getContextPath()%>/servico/detalheGame.jsp">
			<table cellspacing="10" style="width:100%;">
				<thead><caption>Games Disponiveis</caption></thead>
				<tbody>
					<%
						gameModels = gameDao.getGames();
						int col = 0;
						out.print("<tr>");
						for(GameModel game:gameModels){
							if(col==maxCols){
								out.print("<tr>");
								col=0;
							}
							out.print("\n<td>");
							//request.setAttribute("gameId",game.getId());
							//out.print("\n\t <p>ID "+game.getId()+"</p>");
							//out.print("\n\t<input type=\"submit\" value=\""+game.getId()+"\" name=\"id\" ><img width=\"100\" height=\"130\" src=\""+request.getContextPath()+game.getUrl()+"\"alt=\""+game.getTitulo()+"\"><br />");
							out.print("\n\t<input type=\"image\" width=\"100\" height=\"100px\" value=\""+game.getId()+"\" name=\"codGame\" src=\""+request.getContextPath()+game.getUrl()+"\"alt=\""+game.getTitulo()+"\"><br />");
							out.print("\n\t<p class=\"titulo\">"+game.getTitulo()+"</p>");
							out.print("\n</td>");
							col++;
						}
						out.print("</tr>");
					%>
				</tbody>
			</table> 
		</form>
	</body>
</html>